<template>
  <el-select
    :value="value"

    placeholder="请选择"
    clearable
    @change="changedChannelId"
  >
    <el-option
      v-for="item in channelOptions"
      :key="item.id"
      :label="item.name"
      :value="item.id"
    >
    </el-option>
  </el-select>
</template>

<script>
export default {
  props: ['value'],
  data () {
    return {
    //   channel_id: null,
      channelOptions: [
        {
          id: '1',
          name: '前端'
        }
      ]
    }
  },
  created () {
    this.getChannel_id()
  },
  methods: {
    changedChannelId (changedChannelId) {
      if (changedChannelId === '') {
        this.channel_id = null
      }
      this.$emit('input', changedChannelId)
    },

    async getChannel_id () {
      const {
        data: { data }
      } = await this.$http.get('/mp/v1_0/channels')
      // console.log(res.data.data.channels);
      // console.log(data);

      this.channelOptions = data.channels
    }
  }
}
</script>

<style>
</style>
